/*
 * Created on Jun 24, 2005
 *
 */
package com.erclab.internal.xpresso.util;

/**
 * @author Enrique Rodriguez.
 *
 */
public class DataTypeDiscover {

	public static String getFormElementClassHandler(String type){
		String classHandler = "";
		// Decide what kind of element will be created based on the type of column on the table
		if (type.indexOf("int") > 0 || type.indexOf("float") > 0){
			classHandler = "com.erclab.internal.xpresso.formelements.SimpleNumberInputBox";
		} else if ( type.startsWith("varchar") ){
			classHandler = "com.erclab.internal.xpresso.formelements.SimpleInputBox";
		} else if ( type.startsWith("text") || type.indexOf("text") > 0) {
			classHandler = "com.erclab.internal.xpresso.formelements.SimpleTextArea";
		} else if ( type.equals("date")) {
			classHandler = "com.erclab.internal.xpresso.formelements.SimpleDateBox";
		} else {
			classHandler = "com.erclab.internal.xpresso.formelements.SimpleInputBox";
		}
		return classHandler;
	}

	/**
	 * @param type
	 * @return
	 */
	public static String getFormElementDataType(String type) {
		// TODO: Decide if we need this or not ... probably this can be
		// handled by each form element in its client script
		String dataType = "";
		if (type.indexOf("int") > 0 || type.indexOf("float") > 0){
			dataType = "";
		} else if ( type.startsWith("varchar") ){
			dataType = "";
		} else if ( type.startsWith("text") || type.indexOf("text") > 0) {
			dataType = "";
		} else if ( type.equals("date")) {
			dataType = "";
		} else {
			dataType = "";
		}
		return dataType;
	}
}
